<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
    <style>
        #root button {
            padding: 5px;
            margin: 5px;
        }

        #root button.active {
            background: red;
        }

        #root div {
            width: 500px;
            height: 200px;
            background: green;
        }
    </style>
</head>
<body>
    <div id='root'>

    </div>
    <script type='text/babel'>
        class App extends React.Component{
            state={
                index:0
            }
            render(){
                return(
                    <>
                        <button onClick={()=>this.setState({index:0})} className={this.state.index===0?'active':''} >娱乐</button>
                        <button onClick={()=>this.setState({index:1})} className={this.state.index===1?'active':''} >体育</button>
                        <button onClick={()=>this.setState({index:2})} className={this.state.index===2?'active':''} >财经</button>
                        <div style={{display:this.state.index===0?'block':'none'}} >娱乐新闻</div>
                        <div style={{display:this.state.index===1?'block':'none'}} >体育新闻</div>
                        <div style={{display:this.state.index===2?'block':'none'}} >财经新闻</div>
                    </>
                )
            }
        }
        ReactDOM.createRoot(document.getElementById('root')).render(<App/>)

    </script>
</body>
</html>